package com.pactera.jep.service.yapin.eval.sample.controller;

import com.pactera.jep.web.entity.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;

import com.pactera.jep.orm.Filter;
import com.pactera.jep.orm.Order;
import com.pactera.jep.orm.Page;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.pactera.jep.core.exception.ServiceException;
import com.pactera.jep.web.controller.CrudController;
import org.springframework.web.bind.annotation.*;

import com.pactera.jep.service.yapin.eval.sample.model.ValColSampleImpRecord;
import com.pactera.jep.service.yapin.eval.sample.service.ValColSampleImpRecordService;


/**
 *
 * @Author YouName
 * @Date 2020-7-20 13:57:59
 */
@RestController
@RequestMapping("/valcolsampleimprecord")
@Api(description = "估值流程押品与样本选择记录表")
public class ValColSampleImpRecordController extends CrudController<ValColSampleImpRecord> {

    @Autowired
    ValColSampleImpRecordService valColSampleImpRecordService;

    @GetMapping("/{id}")
    @ApiOperation("查询估值流程押品与样本选择记录表")
    public Result get(@PathVariable("id") String colSampleRecordId) {
        return Result.success(valColSampleImpRecordService.get(colSampleRecordId));
    }

    @DeleteMapping("/{id}")
    @ApiOperation("删除估值流程押品与样本选择记录表")
    public Result delete(@PathVariable("id") String colSampleRecordId) {
        return Result.success(valColSampleImpRecordService.deleteByPrimaryKey(colSampleRecordId));
    }

    @PostMapping("/save")
    @ApiOperation("插入估值流程押品与样本选择记录表")
    public Result insert(@RequestBody ValColSampleImpRecord valColSampleImpRecord) {
        return Result.success(valColSampleImpRecordService.insert(valColSampleImpRecord));
    }

    @PostMapping("/update")
    @ApiOperation("更新估值流程押品与样本选择记录表")
    public Result update(@RequestBody ValColSampleImpRecord valColSampleImpRecord) {
        return Result.success(valColSampleImpRecordService.update(valColSampleImpRecord));
    }

    /**
     * 为列表页面做数据准备
     */
    @Override
    protected void prepareQuery(Page<ValColSampleImpRecord> page, List<Filter> filters, List<Order> orders, HttpServletRequest    request) {
        valColSampleImpRecordService.query(page, filters, orders);
    }
}
